# 执法智库 企业管理
from Lib.base.keywords import KeyWords
from selenium.webdriver.common.by import By
from Lib.common.common_function import *
from Lib.base.page_object.login_page import LonginPage
import uuid
import random


class EnterpriseManager(KeyWords):
    url = KeyWords.url + 'enterprise/query'

    def department_sort(self):
        '''
        部门排序
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\enterprise\search_and_sort_department.yaml')
        element_operation(self, data[0]['data'])

    def create_enterprise(self):
        '''
        新建企业
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\enterprise\create_enterprise.yaml')
        element_operation(self, data[0]['data'])

    def enterprise_list_by_risk_grade(self):
        '''
        根据风险等级查询企业
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\enterprise\enterprise_list_by_risk_grade.yaml')
        element_operation(self, data[0]['data'])

    def enterprise_list_by_scale(self):
        '''
        根据规模查询企业
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\enterprise\enterprise_list_by_scale.yaml')
        element_operation(self, data[0]['data'])

    def enterprise_list_by_department(self):
        '''
        根据部门筛选企业
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\enterprise\enterprise_list_by_department.yaml')
        element_operation(self, data[0]['data'])

    def enterprise_search_error(self):
        '''
        搜索企业 错误值
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\enterprise\enterprise_search_error.yaml')
        element_operation(self, data[0]['data'])

    def enterprise_search(self):
        '''
        搜索企业 精确和模糊搜索
        enterprise_detail_and_update.yaml
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\enterprise\enterprise_search.yaml')
        element_operation(self, data[0]['data'])

    def enterprise_detail_and_update(self):
        '''
        查看详情和进行编辑
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\enterprise\enterprise_detail_and_update.yaml')
        element_operation(self, data[0]['data'])

    def enterprise_delete(self):
        '''
        删除企业
        :return:
        '''
        data = get_data_by_yaml(get_path() + r'\Data\element_data\enterprise\enterprise_delete.yaml')
        element_operation(self, data[0]['data'])


if __name__ == '__main__':
    try:
        driver = choose_browser()
        L = LonginPage(driver)
        L.login('kobeAdmin002', 'kobe8888')
        case = EnterpriseManager(driver)
        case.department_sort()
        driver.quit()
    except Exception as E:
        print(E)
        driver.quit()
